<%@ page import="java.sql.*" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加学生</title>
</head>
<body>

<%
    Object oname=session.getAttribute("name");
    if(oname==null){
        request.setAttribute("msg","请登录后查看");
        request.getRequestDispatcher("login.jsp").forward(request,response);
    }
    //1、注册驱动（公司报道）
    Class.forName("com.mysql.cj.jdbc.Driver");
    //2、获取连接（中标造桥）
    Connection connection = DriverManager.getConnection("jdbc:mysql://mysql.zhledu.cn:3306/school", "school", "zhli2008");
    //3、创建执行对象（获取货车）
    Statement stmt = connection.createStatement();
    //4、创建sql语句（下达命令）
    String sql="SELECT MAX(sno)+1 as maxsno from t_user";
    ResultSet rs= stmt.executeQuery(sql);
    long sno=0L;
    if(rs.next()){
        sno=rs.getLong("maxsno");
    }
    connection.close();
%>

<center>
    <form action="doAdd.jsp" method="post">
        <span style="color: red;font-weight: bold">${msg}</span>
        <table border="1px">
            <tr>
                <td>学号</td>
                <td><input type="text" name="sno" value="<%=sno%>" readonly></td>
            </tr>
            <tr>
                <td>姓名</td>
                <td><input type="text" name="name" id="name" value="${name}"></td>
            </tr>
            <tr>
                <td>性别</td>
                <td>
                    <select name="sex" id="sex">
                    <option value="男" selected>男</option>
                    <option value="女">女</option>
                </select>
                </td>
            </tr>
            <tr>
                <td>电话号码</td>
                <td><input type="text" name="phone" id="phone" value="${phone}"></td>
            </tr>
            <tr>
                <td>用户名</td>
                <td><input type="text" name="username" id="username" value="${username}"></td>
            </tr>
            <tr>
                <td>密码</td>
                <td><input type="password" name="password" id="password" value="${password}"></td>
            </tr>
            <tr>
                <td>班级</td>
                <td><input type="text" name="clazz" id="clazz" value="${clazz}"></td>
            </tr>
            <tr>
                <td>根目录</td>
                <td><input type="text" name="homepath" id="homepath" value="${homepath}"></td>
            </tr>
            <tr>
                <td><input type="submit" value="保存"></td>
                <td><input type="reset" value="重置"></td>
            </tr>
        </table>





    </form>


</center>


</body>
</html>
